const fs = require('fs')
const path = require('path')
const basePath = path.resolve(__dirname, '../src')

let dirName = process.argv[2]
moduleName = dirName.replace(dirName[0],dirName[0].toUpperCase());

if (!dirName) {
  console.log(`示例：npm run tep ${capPirName}`)
  process.exit(0)
}

const capPirName = dirName.substring(0, 1).toUpperCase() + dirName.substring(1)

/**
 * vue页面模版
 */
const VueTep = `<template>
  <div class="${dirName}-box">
    ${dirName}-Page
  </div>
</template>

<script lang="ts">
  import { Component, Vue, Prop } from "vue-property-decorator";
  import { Getter, Action, State } from 'vuex-class';

  @Component({})
  export default class ${moduleName} extends Vue {
    // prop
    @Prop({
      required: false,
      default: ''
    }) name!: string;

    created() {
      //
    }
    
    activated() {
      //
    }

    mounted() {
      //
    }

  }
</script>

<style lang="scss" scoped>
  .${dirName}-box {
    width: 100%;
  }
</style>

`

// fs.mkdirSync(`${basePath}/components/${dirName}`) // mkdir

process.chdir(`${basePath}/components`) // cd views
fs.writeFileSync(`${dirName}.vue`, VueTep) // vue 

process.exit(0)